﻿<%@ Page Title="" Language="C#" MasterPageFile="~/ACM.Master" AutoEventWireup="true" CodeBehind="ChangeRequest.aspx.cs" Inherits="ACM.ChangeRequest" %>
<%@ Register Src="~/UserControls/StatusPanel.ascx" TagPrefix="uc" TagName="StatusPanel" %>
<%@ Register Src="~/UserControls/ucYesNo.ascx" TagPrefix="uc" TagName="Agreement" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .input-group
        {
            margin-top: 10px;
        }

        .avoidBootstrap th
        {
            text-align: center;
        }

        .avoidBootstrap td
        {
            padding: 3px;
        }

        .action
        {
            text-align: center;
        }

            .action a:link
            {
                color: #222222;
            }

        table label
        {
            font-weight: normal;
        }

        .Pagination
        {
            line-height: 30px;
            background-color: #ECDBFF;
            text-align: center;
        }

        .Pagination a:link, .Pagination a:visited
        {
            color: black;
        }

        .gridResult th, .gridResult td
        {
            border:1px solid #fff;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="StatusPlaceHolder" runat="server">
    <uc:StatusPanel ID="Status" runat="server"></uc:StatusPanel>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="content" runat="server">
    <div class="page-header" style="margin-top: 0;">
        <h1>รายการคำขอเปลี่ยน Dealer</h1>
    </div>

    <div class="row" style="margin-top: 20px;">
        <div class="avoidBootstrap">

            <asp:RadioButtonList ID="rdoList" runat="server" RepeatDirection="Horizontal" AutoPostBack="true" OnSelectedIndexChanged="rdoList_SelectedIndexChanged">
                <asp:ListItem Selected="True" Text="&nbsp;รายการคำร้องของคุณ&nbsp;&nbsp;&nbsp;" Value="REQ_BY_U"></asp:ListItem>
                <asp:ListItem Text="&nbsp;รายการคำร้องที่ส่งถึงคุณ" Value="REQ_TO_U"></asp:ListItem>
            </asp:RadioButtonList>

            <asp:MultiView ID="mtvTab" runat="server">
                <asp:View ID="View1" runat="server">
                    <asp:GridView ID="grdYourRequest" runat="server" Width="100%" CellPadding="4" EnableModelValidation="True" ForeColor="#333333" GridLines="None" AutoGenerateColumns="false" CssClass="gridResult" OnRowDataBound="grdYourRequest_RowDataBound" OnRowCommand="grdYourRequest_RowCommand">
                        <AlternatingRowStyle BackColor="White" />
                        <Columns>
                            <asp:TemplateField HeaderText="No." SortExpression="row_no">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("RowNumber") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" Width="30px" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="VIN">
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("vin") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle Height="30px" HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="ร้องขอไปยัง">
                                <ItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("dealer_name") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="สถานะ">
                                <ItemTemplate>
                                    <asp:Label ID="Label4" runat="server" Text='<%# Eval("change_status") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <HeaderTemplate>
                                    <span class="glyphicon glyphicon-edit"></span>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <asp:LinkButton ID="lnkKeyIn" runat="server" Visible="false" CommandName="KeyIn" CommandArgument='<%# Eval("tx_id") %>'>ลงข้อมูลการขาย</asp:LinkButton>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />                      
                            </asp:TemplateField>
                                       
                        </Columns>
                        <EditRowStyle BackColor="#2461BF" />
                        <EmptyDataTemplate>
                            <div class="alert alert-danger" role="alert" style="text-align: center; margin-bottom: 0;">
                                <p>ไม่พบคำร้องขอ</p>
                            </div>
                        </EmptyDataTemplate>
                        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Height="40" HorizontalAlign="Center" VerticalAlign="Middle" />
                        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" Height="30" />
                        <RowStyle BackColor="#EFF3FB" />
                        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    </asp:GridView>
                </asp:View>
                <asp:View ID="View2" runat="server">
                    <asp:GridView ID="grdRequestToYou" runat="server" Width="100%" CellPadding="4" EnableModelValidation="True" ForeColor="#333333" GridLines="None" AutoGenerateColumns="false" CssClass="gridResult">
                        <AlternatingRowStyle BackColor="White" />
                        <Columns>
                            <asp:TemplateField HeaderText="No." SortExpression="row_no">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("RowNumber") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" Width="30px" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="VIN">
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("vin") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle Height="30px" HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="จากผู้แทนจำหน่าย">
                                <ItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("dealer_name") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="สถานะ">
                                <ItemTemplate>
                                    <asp:Label ID="Label4" runat="server" Text='<%# Eval("change_status") %>'></asp:Label>
                                </ItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                                       
                            <asp:TemplateField>
                                <HeaderTemplate>
                                    <div class="ucYesNo">
                                        <div style="width:50%;text-align:center;border-right:1px solid;float:left;line-height:30px;">ยอมรับ</div>
                                        <div style="width:49.8%;text-align:center;float:left;line-height:30px;">ไม่ยอมรับ</div>
                                        <div style="clear:both;"></div>
                                    </div>
                                </HeaderTemplate>
                                <ItemTemplate>
                                    <uc:Agreement ID="ucAgreement" runat="server" YesValue="ยอมรับ" NoValue="ไม่ยอมรับ" tx_id='<%# Eval("tx_id") %>' Value='<% Eval("change_request_status") %>' ></uc:Agreement>
                                </ItemTemplate>                        
                            </asp:TemplateField>
                                       
                        </Columns>
                        <EditRowStyle BackColor="#2461BF" />
                        <EmptyDataTemplate>
                            <div class="alert alert-danger" role="alert" style="text-align: center; margin-bottom: 0;">
                                <p>ไม่พบคำร้องขอ</p>
                            </div>
                        </EmptyDataTemplate>
                        <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Height="40" HorizontalAlign="Center" VerticalAlign="Middle" />
                        <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" Height="30" />
                        <RowStyle BackColor="#EFF3FB" />
                        <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    </asp:GridView>
                    <div class="text-right">
                        <br />
                        <asp:Button ID="btnChangeReqSubmit" runat="server" Text="บันทึก" CssClass="btn btn-primary" Visible="false" OnClick="btnChangeReqSubmit_Click" />
                    </div>
                </asp:View>
            </asp:MultiView>

    </div>
    </div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="script" runat="server">
    <script type="text/javascript">
        ActiveMenuIndex(2);

        $(document).ready(function () {
            $(".chkYes input").change(function () {
                var me = $(this);
                if (me.is(':checked')) {
                    me.parentsUntil($("td"), ".ucYesNo").find("span.chkNo").children("input").attr('checked', false);                    
                }
            });

            $(".chkNo input").change(function () {
                var me = $(this);
                if (me.is(':checked')) {
                    me.parentsUntil($("td"), ".ucYesNo").find("span.chkYes").children("input").attr('checked', false);
                }
            });
        });
    </script>
</asp:Content>
